<template>
  <a-drawer
    :title="title"
    :width="width"
    placement="right"
    :closable="false"
    @close="close"
    destroyOnClose
    :visible="visible">
    <cy-emission-unit-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal></cy-emission-unit-form>
    <div class="drawer-footer" style="float:right">
      <span style="margin-right: 10px;">
        <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button>
      </span>

      <span style="margin-right: 10px;">
        <a-button v-if="!disableSubmit"  @click="handleOk" type="primary" style="margin-bottom: 0;">提交</a-button>
      </span>

    </div>
  </a-drawer>



</template>

<script>

  import CyEmissionUnitForm from './CyEmissionUnitForm'
  export default {
    name: 'CyEmissionUnitModal',
    components: {
      CyEmissionUnitForm
    },
    data () {
      return {
        title:'',
        width:600,
        visible: false,
        disableSubmit: false
      }
    },
    methods: {
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>